import React from 'react';
import {useSelector} from "../../redux/hooks";

export const Writer: React.FC = () => {
  const writers = useSelector(state => state.writer)
  const randomNum = () => (Math.random() * 1000).toFixed(1)
  return (
    <div className="writerWrapper">
      <p className="head">推荐作者</p>
      {writers.map(writer => {
        return (
          <div className="writer" key={writer.id}>
            <img src={writer.avatar} alt={writer.name} className="avatar"/>
            <div className="info">
              <h4 className="name">{writer.name}</h4>
              <p className="desc">写了{randomNum()}k字</p>
            </div>
          </div>
        )
      })}
    </div>
  );
};
